<?php 
$data['page_selected'] = 'query';
$this->load->view('constants/header', $data);?>

<script type="text/javascript">
$(function() {
	var availableTags = new Array();
	<?php for($i=0; $i <  count($clubs) ; $i++){?>
		availableTags[<?php echo($i); ?>] = {label: "<?php echo($clubs[$i]['nombre']);?>",
											 value: "<?php echo($clubs[$i]['id_club']);?>"};
	<?php } ?>	
	
	$('#tags').autocomplete({
		minLength: 2,
		source: availableTags,
		focus: function(event, ui) {
			$('#tags').val(ui.item.label);
			return false;
		},
		select: function(event, ui) {
			$('#tags').val(ui.item.label);
			$('#club').val(ui.item.value);				
			return false;
		}
	});
});
</script>

<div id="site_content">
	<?php $this->load->view('constants/sidebar'); ?> 
    <div id="content">
        <!-- insert the page content here -->
	    <?php $this->load->view('query/menu'); ?>
        <br /><br /><br /><br />
  		<h3 align="center">Club</h3>
        <h1>Miembros de un club</h1>
        
        <table width="100%">
        	<tr>
             	<td align="center">
                    <form method="post" action="<?php echo base_url(); ?>query/get_club">
                        Buscar&nbsp;
                        <input id="tags" /> <input type="hidden" name="club" id="club"/>
                        &nbsp;
                        <input type="image" alt="Submit" src="<?php echo base_url().IMG; ?>search_2.png" width="20px" height="20px" title="Buscar">
                    </form>
		        </td>
        	</tr>
        </table>
        
        <?php if(isset($users)){ ?>
           		<table width="100%" align="center">
                    <thead>
                        <th align="center">
                            C&eacute;dula
                        </th>
                        <th align="center">
                            Nombre
                        </th>
                        <th align="center">
                            Tipo de Buddy
                        </th>
                        <th align="center">
                            Club perteneciente
                        </th>
                        <th align="center">
                            Correo electr&oacute;nico
                        </th>
                    </thead>
                <?php foreach($users as $u){ ?>
                    <tr>
                        <td align="center">
                            <?php echo $u['ci_integrante']; ?>
                        </td>
                        <td align="center">
                            <a href="<?php echo base_url(); ?>query/get_user/<?php echo $u['id_integrante']; ?>">
                                <?php echo $u['nombre'].' '.$u['apellido']; ?>
                            </a>
                        </td>
                        <td align="center">
                            <?php echo $u['tipo_buddy_descripcion']; ?>
                        </td>
                        <td align="center">
                            <?php echo $u['club_nombre']; ?>
                        </td>
                        <td align="center">
                            <?php echo $u['email']; ?>
                        </td>
                    </tr>
                <?php } ?>
                    <tr>
                        <td colspan="5" align="center">
                            <?php  echo $this->pagination->create_links(); ?>
                        </td>
                    </tr>
                </table>
        <?php } ?>
    </div>
</div>
<?php $this->load->view('constants/footer'); ?>